package com.codinghero.zqlb.spider.handler;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import com.codinghero.zqlb.match.MatchUtils;
import com.codinghero.zqlb.match.SoccerMatch;
import com.codinghero.zqlb.match.SoccerMatchComparator;

public class HotMatchFilterHandler implements MatchHandler {

	@Override
	public <T extends SoccerMatch> void handle(List<T> list) {
		// filter the focuesd index < 1
		if (list != null) {
			Iterator<T> iter = list.iterator();
			while (iter.hasNext()) {
				SoccerMatch match = iter.next();
				if (MatchUtils.isFocused(match) < 1)
					iter.remove();
			}
		}
		// sort
		Collections.sort(list, new SoccerMatchComparator());
		Collections.reverse(list);
	}

}
